export interface IPoint {
    x: number;
    y: number;
}

export class Point implements Readonly<IPoint> {
    #x: number;
    #y: number;

    constructor(point: IPoint);
    constructor(x: number, y: number);
    constructor(x: IPoint | number, y?: number) {
        if (typeof x === "number") {
            this.#x = x;
            this.#y = y!;
        } else {
            this.#x = x.x;
            this.#y = x.y;
        }
    }

    get x(): number {
        return this.#x;
    }

    get y(): number {
        return this.#y;
    }

    set(x: number = this.#x, y: number = this.#y): void {
        this.#x = x;
        this.#y = y;
    }

    move(offsetX: number = 0, offsetY: number = 0): Point {
        return new Point(this.x + offsetX, this.y + offsetY);
    }
}
